package ddbs;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Configuration {
    Map<String, String> confs = null;;

    public Configuration(String filename) throws IOException {
        confs = new HashMap<String, String>();
        loadConfigurations(filename);
    }

    public String getConf(String key) {
        return confs.get(key);
    }

    private void loadConfigurations(String filename) throws IOException {
        String line = null;
        BufferedReader br = new BufferedReader(new InputStreamReader(
                new FileInputStream(filename)));
        while ((line = br.readLine()) != null) {
            String kv[] = line.trim().split("=");
            if (kv.length != 2)
                continue;
            confs.put(kv[0].trim(), kv[1].trim());
        }
    }
}
